import { mockRequest } from '../index'
import { myrequest } from '../index'
import type {
  GoodsList,
  selectGoodsT,
  approveType,
  approveTable,
  purchaseTable
} from './type'
import type { requestType } from '../type'

enum GoodsApi {
  selectGoods = '/goods/infor/select',
  insertApprove = '/goods/approve/insert',
  selectApprove = '/goods/approve/select',
  selectPurchase = '/goods/purchase/select',
  deleteApprove = '/goods/approve/delete'
}
//`${GoodsApi.selectGoods}?currentPage=${selectData.currentPage}&nextPage=${selectData.nextPage}&name=''`
/* 请求物资列表 */
export function selectGoodsRequest(selectData: selectGoodsT) {
  return myrequest.get<requestType<GoodsList>>({
    url: GoodsApi.selectGoods,
    params: selectData
  })
}

/* 上交物资申请 */
export function insertApproveRequest(approveData: approveType) {
  return myrequest.post<requestType>({
    url: GoodsApi.insertApprove,
    data: approveData
  })
}

/* 请求物资申请表 */
export function selectApproveRequest(selectData: selectGoodsT) {
  return myrequest.get<requestType<GoodsList>>({
    url: GoodsApi.selectApprove,
    params: selectData
  })
}

/* 请求物资采购表 */
export function selectPurchaseRequest(selectData: selectGoodsT) {
  return myrequest.get<requestType<GoodsList>>({
    url: GoodsApi.selectPurchase,
    params: selectData
  })
}

//删除接口
export function deleteTableRequest(module: string, ids: number[]) {
  return myrequest.delete<requestType>({
    url: `/goods/${module}/delete`,
    data: ids
  })
}
